/*    */ package com.asiainfo.dacp.catalog.controller;
/*    */ 
/*    */ import com.asiainfo.dacp.catalog.util.JsonPropertiesReader;
/*    */ import com.asiainfo.dacp.jdbc.JdbcTemplate;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.ui.Model;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.context.request.WebRequest;
/*    */ 
/*    */ 
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"/catalog/view"})
/*    */ public class CatalogRouteController
/*    */ {
/* 21 */   private static Logger LOG = LoggerFactory.getLogger(CatalogRouteController.class);
/*    */   
/*    */   private Map getCfg(String id) {
/* 24 */     String path = "/conf/catalog.json";
/* 25 */     Map map = JsonPropertiesReader.getInstance().readProperties(path);
/* 26 */     Map cfg = (Map)map.get(id);
/* 27 */     if (cfg == null) {
/* 28 */       LOG.warn("configuration of id '{}' not found,retuen default catalog", id);
/* 29 */       cfg = (Map)map.get("default");
/*    */     }
/* 31 */     return cfg;
/*    */   }
/*    */   
/*    */   @RequestMapping(value={"/{id}_catalog"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String getCatalog(WebRequest request, Model model, @PathVariable String id) {
/* 36 */     model.addAllAttributes(getCfg(id));
/* 37 */     return "catalog/card/__cards";
/*    */   }
/*    */   
/*    */   @RequestMapping(value={"/{id}_profile"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String getProfile(WebRequest request, Model model, @PathVariable String id) {
/* 42 */     model.addAllAttributes(getCfg(id));
/*    */     
/* 44 */     String xmlid = request.getParameter("id");
/* 45 */     JdbcTemplate jdbc = new JdbcTemplate();
/* 46 */     Map data = jdbc.queryForMap("select * from meta_obj where xmlid='" + xmlid + "'");
/* 47 */     List<Map<String, Object>> fields = jdbc.queryForList("select * from meta_field where xmlid='" + xmlid + "'");
/* 48 */     List<Map<String, Object>> entities = jdbc.queryForList("select * from tablefile where xmlid='" + xmlid + "'");
/* 49 */     data.put("fields", fields);
/* 50 */     data.put("entities", entities);
/* 51 */     model.addAttribute("data", data);
/* 52 */     return "catalog/card/__profile";
/*    */   }
/*    */ }


/* Location:              C:\Users\my\.m2\repository\com\asiainfo\dacp\dacp-dataos\1.0.0\dacp-dataos-1.0.0.jar!\com\asiainfo\dacp\catalog\controller\CatalogRouteController.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */